package me.zhengjie.modules.app.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import lombok.extern.slf4j.Slf4j;
import me.zhengjie.modules.app.domain.GameRounds;
import me.zhengjie.modules.app.domain.dto.GameRoundsDto;
import me.zhengjie.modules.app.domain.dto.GameRoundsStatisticsDto;
import me.zhengjie.modules.app.mapper.GameRoundsMapper;
import me.zhengjie.modules.app.service.GameRoundsService;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
* @author xz
* @date 2025/06/23
*/
@Slf4j
@Service
public class GameRoundsServiceImpl extends ServiceImpl<GameRoundsMapper, GameRounds> implements GameRoundsService {

    /**
     * 新增记录
     * @param dataModel
     * @return
     */
    @Override
    public int insertData(GameRounds dataModel){
        Date insertDate=new Date();
        dataModel.setCreateTime(insertDate);
        dataModel.setUpdateTime(insertDate);
        return getBaseMapper().insert(dataModel);
    }

    @Override
    public int updateData(GameRounds gameRounds) {
        gameRounds.setUpdateTime(new Date());
        return getBaseMapper().updateById(gameRounds);
    }

    @Override
    public Integer findByRecordIdCount(String recordId) {
        return getBaseMapper().findByRecordIdCount(recordId);
    }

    @Override
    public GameRoundsDto findOne(Long id) {
        return getBaseMapper().findOne(id);
    }

    @Override
    public GameRoundsStatisticsDto totalRoundsInfo(Long userId) {
        return getBaseMapper().totalRoundsInfo(userId);
    }
}
